#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long s = 0, sh = 0, shy = 0;
    for (int i = 0; i < n; i++)
    {
        char tmp;
        cin >> tmp;
        if (tmp == 's') ++s;
        if (tmp == 'h') sh += s;
        if (tmp == 'y') shy += sh;
    }
    cout << shy << endl;
    return 0;
}